<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- HTML5 shim for IE8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <![endif]-->


    <link href="__ADMIN_TMPL__/public/assets/themes/{:cmf_get_admin_style()}/bootstrap.min.css" rel="stylesheet">
    <link href="__ADMIN_TMPL__/public/assets/simpleboot3/css/simplebootadmin.css" rel="stylesheet">
    <link href="__ADMIN_TMPL__/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="__STATIC__/css/cityPicker.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        form .input-order {
            margin-bottom: 0px;
            padding: 0 2px;
            width: 42px;
            font-size: 12px;
        }

        form .input-order:focus {
            outline: none;
        }

        .table-actions {
            margin-top: 5px;
            margin-bottom: 5px;
            padding: 0px;
        }

        .table-list {
            margin-bottom: 0px;
        }

        .form-required {
            color: red;
        }
    </style>
    <script type="text/javascript">
        //全局变量
        var GV = {
            ROOT: "__ROOT__/",
            WEB_ROOT: "__WEB_ROOT__/",
            JS_ROOT: "static/js/",
            APP: '{$Request.module}'/*当前应用名*/
        };
    </script>
    <script src="__ADMIN_TMPL__/public/assets/js/jquery-1.10.2.min.js"></script>
    <script src="__STATIC__/js/wind.js"></script>
    <script src="__STATIC__/js/cityPicker.js"></script>
    <script src="__STATIC__/js/cityData.js"></script>
    <script src="__ADMIN_TMPL__/public/assets/js/bootstrap.min.js"></script>
    <script>
        Wind.css('artDialog');
        Wind.css('layer');
        $(function () {
            $("[data-toggle='tooltip']").tooltip({
                container:'body',
                html:true,
            });
            $("li.dropdown").hover(function () {
                $(this).addClass("open");
            }, function () {
                $(this).removeClass("open");
            });
        });
    </script>
    <if condition="APP_DEBUG">
        <style>
            #think_page_trace_open {
                z-index: 9999;
            }
        </style>
    </if>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:cmf_plugin_url('QbtVote://AdminIndex/index')}">投票列表</a></li>
        <li class="active"><a href="{:cmf_plugin_url('QbtVote://AdminIndex/add')}">添加投票</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form margin-top-20"
          action="{:cmf_plugin_url('QbtVote://AdminIndex/edit')}">
        <input type="hidden" name="id" value="{$info.id}">
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>标题</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="name" value="{$info.name}" required>
            </div>
        </div>

		<div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>单次可投票数</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="everytime" value="{$info.everytime}" required>
                <p class="help-block">等于1为单选,大于1为多选</p>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>可参与城市</label>
            <div class="col-md-6 col-sm-10">
                <button type="button" class="btn" onclick="addcity()">添加</button>（不添加则为不限制）
                <div class="city" style="margin-top: 10px;">
                    <volist name="info['city']" id="v" key="k">
                    <div style="position: relative;"><input type="text" id="city{$k}" class="form-control" name="city[]" value="{$v}" readonly="readonly"><a href="javascript:void(0);" style="color: #f00;position: absolute;right: 5px;bottom: 5px;" onclick="del(this)">×</a></div>
                    <script>
                        var cityPicker = new IIInsomniaCityPicker({
                            data: cityData,
                            target: '#city{$k}',
                            valType: 'k-v',
                            callback: function(city_id){
                            }
                        });
                        cityPicker.init();
                    </script>
                    </volist>
                </div>
            </div>
        </div>
        
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>时间区间</label>
            <div class="col-md-6 col-sm-10 form-inline" >
             	<input type="text" class="form-control js-bootstrap-datetime" name="start_time" required
	               value="{$start_time|default=''}"
	               style="width: 190px;" autocomplete="off"> -
        		<input type="text" class="form-control js-bootstrap-datetime" name="end_time" required
	               value="{$end_time|default=''}"
	               style="width: 190px;" autocomplete="off">
            </div>
        </div>
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-primary js-ajax-submit">{:lang("SAVE")}</button>
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script>
    function addcity() {
        var id = new Date().getTime()+Math.ceil(Math.random()*10);
        var str = '<div style="position: relative;"><input type="text" id="city'+id+'" class="form-control" name="city[]" value="" readonly="readonly"><a href="javascript:void(0);" style="color: #f00;position: absolute;right: 5px;bottom: 5px;" onclick="del(this)">×</a></div>';
        $('.city').append(str);
        var cityPicker = new IIInsomniaCityPicker({
            data: cityData,
            target: '#city'+id,
            valType: 'k-v',
            callback: function(city_id){
            }
        });
        cityPicker.init();
    }

    function del(a) {
        $(a).parent().remove();
    }
</script>
</body>
</html>